package com.loiot.baqi.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.loiot.baqi.controller.response.Pager;
import com.loiot.baqi.dao.ZpRecommendFlowRollbackListDao;
import com.loiot.baqi.service.ZpRecommendFlowRollbackListService;
import com.loiot.baqi.pojo.ZpRecommendFlowRollbackList;
import com.loiot.baqi.pojo.ZpJlJobLevels;


/**
 * 企业对接人流程驳回 逻辑类。
 * 
 * @author  wangzx 
 * @creation 2016-04-22
 */
@Service("zpRecommendFlowRollbackListService")
@Transactional
public class ZpRecommendFlowRollbackListService{
    
    private Logger log = LoggerFactory.getLogger(this.getClass());
    
    @Resource
	private ZpRecommendFlowRollbackListDao zpRecommendFlowRollbackListDao;
	
	
	 /**
     * 查询 企业对接人流程驳回列表分页
     * 
     * @param name 企业对接人流程驳回名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<ZpRecommendFlowRollbackList> queryZpRecommendFlowRollbackListListPage(HashMap<String,Object> pMap, int pageIndex)throws Exception {

        // 查询企业对接人流程驳回列表总条数
        int totalResults = zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackListListCount(pMap);

        // 构造一个分页器
        Pager<ZpRecommendFlowRollbackList> pager = new Pager<ZpRecommendFlowRollbackList>(totalResults, pageIndex);

        // 查询企业对接人流程驳回列表
        List<ZpRecommendFlowRollbackList> zpRecommendFlowRollbackListList = zpRecommendFlowRollbackListDao.queryZpRecommendFlowRollbackListList(pMap, pager.getSkipResults(),
                pager.getMaxResults());
        pager.setData(zpRecommendFlowRollbackListList);
        return pager;
    }
    
    
    
    
    /**
     * 查询 企业对接人流程驳回（假）分页
     * 
     * @param name 企业对接人流程驳回名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<ZpRecommendFlowRollbackList> queryFlasePageList(HashMap<String,Object> pMap, int pageIndex)throws Exception {
    	//假分页
    	Pager<ZpRecommendFlowRollbackList> pager = this.setPkList(pMap,pageIndex);
    	List<ZpRecommendFlowRollbackList> zpRecommendFlowRollbackListList = zpRecommendFlowRollbackListDao.queryZpRecommendFlowRollbackListList(pMap);
        pager.setData(zpRecommendFlowRollbackListList);
        return pager;
    }
    
    /**
     * 设置 假分页id集合到Map中
     * @param pMap
     * @param pageIndex
     * @return
     * @throws Exception
     */
    public Pager<ZpRecommendFlowRollbackList> setPkList(HashMap<String,Object> pMap,int pageIndex) throws Exception{
    	  // 查询职位匹配信息列表总条数
        List<ZpRecommendFlowRollbackList> list = zpRecommendFlowRollbackListDao.queryZpRecommendFlowRollbackListList(pMap);
        // 构造一个分页器
        Pager<ZpRecommendFlowRollbackList> pager = new Pager<ZpRecommendFlowRollbackList>(list.size(), pageIndex, 5,list);
        List<ZpRecommendFlowRollbackList> idsList = pager.getCurrentPageData();
        List<Long> ids =this.getIds(idsList);
        pMap.put("ids", ids);
        return pager;
    }
	
	 /**
     * 添加 企业对接人流程驳回
     * 
     * @param p 参数对象
     */
    public ZpRecommendFlowRollbackList addZpRecommendFlowRollbackList(ZpRecommendFlowRollbackList p)throws Exception {
       return  zpRecommendFlowRollbackListDao.addZpRecommendFlowRollbackList(p);
    }
    
    /**
     * 修改 企业对接人流程驳回
     * 
     * @param p 参数对象
     */
    public void updateZpRecommendFlowRollbackList(ZpRecommendFlowRollbackList p)throws Exception {
        zpRecommendFlowRollbackListDao.updateZpRecommendFlowRollbackList(p);
    }
    
    /**
     * 修改 企业对接人流程驳回
     * 
     * @param p 参数对象
     */
    public void updateZpRecommendFlowRollbackList(HashMap<String,Object> pMap)throws Exception {
        zpRecommendFlowRollbackListDao.updateZpRecommendFlowRollbackList(pMap);
    }
    
    /**
     * 删除  企业对接人流程驳回
     * 
     * @param id 主键
     */
    public void deleteZpRecommendFlowRollbackList(java.lang.Long id)throws Exception {
        zpRecommendFlowRollbackListDao.deleteZpRecommendFlowRollbackList(id);
    }
    
    /**
     * 删除  企业对接人流程驳回
     * 
     * @param id 主键
     */
    public void deleteZpRecommendFlowRollbackList(ZpRecommendFlowRollbackList p)throws Exception {
        zpRecommendFlowRollbackListDao.deleteZpRecommendFlowRollbackList(p);
    }
    
    /**
     * 获得  企业对接人流程驳回
     * 
     * @param id 企业对接人流程驳回Id
     * 
     * @return 返回与ID匹配的企业对接人流程驳回
     */
    public ZpRecommendFlowRollbackList getZpRecommendFlowRollbackListById(java.lang.Long id)throws Exception {
        return  zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackListById(id);
    }
    
    /**
     * 获得  企业对接人流程驳回
     * 
     * @param id 企业对接人流程驳回Id
     * 
     * @return 返回与ID匹配的企业对接人流程驳回
     */
    public ZpRecommendFlowRollbackList getZpRecommendFlowRollbackListById(java.lang.Long id,Long accountId)throws Exception {
        return  zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackListById(id,accountId);
    }
    
    
    /**
     * 获得  企业对接人流程驳回
     * 
     * @param id 企业对接人流程驳回Id
     * 
     */
    public ZpRecommendFlowRollbackList getZpRecommendFlowRollbackList(HashMap<String,Object> pMap)throws Exception {
    	return (ZpRecommendFlowRollbackList) zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackList(pMap);
    }
    /**
     * 获得  企业对接人流程驳回
     * 
     * @param name 企业对接人流程驳回名称
     * 
     * @return 返回与NAME匹配的企业对接人流程驳回
     */
    public ZpRecommendFlowRollbackList getZpRecommendFlowRollbackListByName(String name)throws Exception {
        return  zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackListByName(name);
    }
    
    /**
     * 查询 企业对接人流程驳回列表
     * @return 企业对接人流程驳回列表
     */
    public List<ZpRecommendFlowRollbackList> queryZpRecommendFlowRollbackListList(HashMap<String,Object> pMap)throws Exception {
        return  zpRecommendFlowRollbackListDao.queryZpRecommendFlowRollbackListList(pMap);
    }
    
    /**
     * 查询 企业对接人流程驳回列表
     * @return 企业对接人流程驳回列表
     */
    public List<ZpRecommendFlowRollbackList> queryZpRecommendFlowRollbackListList(ZpRecommendFlowRollbackList p)throws Exception {
        return  zpRecommendFlowRollbackListDao.queryZpRecommendFlowRollbackListList(p);
    }
    
    /**
     * 查询  企业对接人流程驳回列表条数
     * 
     * @param name 企业对接人流程驳回名称
     * @return 企业对接人流程驳回列表条数
     */
    
    public int getZpRecommendFlowRollbackListListCount(HashMap<String,Object> pMap)throws Exception {
        return  zpRecommendFlowRollbackListDao.getZpRecommendFlowRollbackListListCount(pMap);
    }
    
    /**
     * 查询id集合
     * @return
     */
    public List<Long> getIds(List<ZpRecommendFlowRollbackList> list) {
    	List<Long> idsList = null;
        if(list!=null && list.size()>0) {
        	idsList = new ArrayList<Long>();
        	for (ZpRecommendFlowRollbackList b : list) {
            	idsList.add(null);
            }
        }
        return idsList;
    }
    
    /**
     * 统计 企业对接人流程驳回列表
     * 
     * @return 企业对接人流程驳回列表
     */
    public List<HashMap<String,Object>> statisticsZpRecommendFlowRollbackListInfo(HashMap<String, Object> pMap )throws Exception {
    	return  zpRecommendFlowRollbackListDao.statisticsZpRecommendFlowRollbackListInfo(pMap);
    }
}
